FROM php:7.3-apache

LABEL php.image.authors="jackWang@email.com"

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y --no-install-recommends \
      vim \
      curl \
      libz-dev \
      libpq-dev \
      libjpeg-dev \
      libpng-dev \
      libfreetype6-dev \
      libssl-dev \
      libmcrypt-dev \
      zip \
      unzip \
      build-essential \
      libaio1 \
      libzip-dev \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
    && rm /var/log/lastlog /var/log/faillog

ADD instantclient-basic-linux.x64-21.4.0.0.0dbru.zip  /usr/lib/oracle/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip
ADD instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip  /usr/lib/oracle/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip

RUN unzip /usr/lib/oracle/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip -d /usr/lib/oracle/ \
    && rm /usr/lib/oracle/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip \
    && unzip /usr/lib/oracle/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip -d /usr/lib/oracle/ \
    && rm /usr/lib/oracle/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip \
    && echo /usr/lib/oracle/instantclient_21_4 > /etc/ld.so.conf.d/oracle-instantclient.conf \
    && ldconfig

ENV LD_LIBRARY_PATH /usr/lib/oracle/instantclient_21_4
ENV ORACLE_HOME /usr/lib/oracle/instantclient_21_4

RUN docker-php-ext-install zip pdo_mysql bcmath opcache pcntl mysqli \
    && docker-php-ext-configure oci8 --with-oci8=instantclient,/usr/lib/oracle/instantclient_21_4 \
    && docker-php-ext-install -j$(nproc) oci8 \
    && docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/usr/lib/oracle/instantclient_21_4 \
    && docker-php-ext-install -j$(nproc) pdo_oci \
    && docker-php-ext-configure gd \
        --with-jpeg-dir=/usr/lib \
        --with-freetype-dir=/usr/include/freetype2 && \
        docker-php-ext-install gd \
    && pecl install mcrypt && docker-php-ext-enable mcrypt 

RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load